package io;

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

/**
 * 完成简易记事本
 * 程序启动后将用户输入的每一行字符串都按行写入到note.txt中，用户输入exit时退出
 * 要求，完成4层流连接
 */
public class Test3 {
    public static void main(String[] args) throws FileNotFoundException {
        FileOutputStream fos = new FileOutputStream("note.txt");
        OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8);
        BufferedWriter bw = new BufferedWriter(osw);
        PrintWriter pw = new PrintWriter(bw,true);
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入内容，输入exit退出");
        while (true) {
            String str = sc.nextLine();
            if ("exit".equalsIgnoreCase(str)){
        break;}
            pw.println(str);//写入字符串
        }
    }
}